﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using FW;

namespace kserv
{
    public class rotas
    {
        static public string qualrota()
        {
            configSRV csrv = new configSRV();
            fwlog log = new fwlog(csrv.TEMPDIR + "\\log.dbiKcad.txt", csrv.TIPOLOG);
            // System.Diagnostics.Debugger.Launch();
            kservDataContext db = new kservDataContext(csrv.DBINFECONNSTRING);

            string constr = csrv.DBINFECONNSTRING;

            tb_wsRota tbrota = (from tb in db.tb_wsRotas
                                where tb.ativo == true
                                orderby tb.dt_ult ascending
                                select tb).Take(1).Single();

            string rota = tbrota.rurl;



            tbrota.dt_ult = DateTime.Now;
            db.ExecuteCommand("update tb_wsrotas set dt_ult = getdate() where PK_ID = {0}", tbrota.PK_ID);
            //db.SubmitChanges();



            return rota;
        }

    }
}
